<template>
  <div class="app-container calendar-list-container">
    <div class="filter-container">
      <el-input @keyup.enter.native="handleFilter" style="width: 200px;" class="filter-item" placeholder="姓名" v-model="listQuery.key">
      </el-input>
      <el-button class="filter-item" type="primary" v-waves icon="search" @click="handleFilter">搜索</el-button>

    </div>

    <el-table :key='tableKey' :data="list" v-loading="listLoading" element-loading-text="不需要时间" border fit
              highlight-current-row style="width: 100%">

      <el-table-column align="center" label="姓名">
        <template scope="scope">
          <span>{{ scope.row.name }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="银行名称">
        <template scope="scope">
          <span>{{ scope.row.bankname }}</span>
        </template>
      </el-table-column>

      <el-table-column align="center" label="移动电话">
        <template scope="scope">
          <span>{{ scope.row.mobile }}</span>
        </template>
      </el-table-column>


      <el-table-column align="center" label="部门电话">
        <template scope="scope">
          <span>{{ scope.row.depttel }}</span>
        </template>
      </el-table-column>
<!--
      <el-table-column align="center" label="家庭地址">
        <template scope="scope">
          <span>{{ scope.row.homeaddr }}</span>
        </template>
      </el-table-column>

      <el-table-column align="center" label="家庭电话">
        <template scope="scope">
          <span>{{ scope.row.hometel }}</span>
        </template>
      </el-table-column>

      <el-table-column align="center" label="卡号">
        <template scope="scope">
          <span>{{ scope.row.cardno }}</span>
        </template>
      </el-table-column>

-->
      <el-table-column align="center" label="账单">
        <template scope="scope">
          <span>{{ scope.row.balance }}</span>
        </template>
      </el-table-column>


      <el-table-column align="center" label="应付">
        <template scope="scope">
          <span>{{ scope.row.lastpaysum }}</span>
        </template>
      </el-table-column>



      <el-table-column align="center" label="违约金">
        <template scope="scope">
          <span>{{ scope.row.wyj }}</span>
        </template>
      </el-table-column>



      <el-table-column label="操作">
        <template scope="scope">
          <el-button size="small" type="success"
                     @click="gotoCaseInfo(scope.row)">催收
          </el-button>

        </template>
      </el-table-column>
    </el-table>
    <div v-show="!listLoading" class="pagination-container">
      <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
                     :current-page.sync="listQuery.page"
                     :page-sizes="[10,20,30, 50]" :page-size="listQuery.limit"
                     layout="total, sizes, prev, pager, next, jumper" :total="total">
      </el-pagination>
    </div>

  </div>
</template>

<script>
  import { fetchList, addObj, putObj, delObj } from '@/api/case_info'
  import waves from '@/directive/waves/index.js' // 水波纹指令
  import { mapGetters } from 'vuex'

  export default {
    name: 'table_case_info',
    directives: {
      waves
    },
    data() {
      return {
        list: null,
        total: null,
        listLoading: true,
        listQuery: {
          bankname: this.$route.query.bankname,
          page: 1,
          limit: 20
        },
        rules: {
        },
        form: {
        },
        dialogFormVisible: false,
        dialogStatus: '',
        case_info_add: true,
        case_info_upd: false,
        case_info_del: false,
        textMap: {
          update: '编辑',
          create: '创建'
        },
        tableKey: 0
      }
    },
    computed: {
      ...mapGetters([
        'permissions'
      ])
    },
    filters: {
      statusFilter(status) {
        const statusMap = {
          0: '有效',
          1: '无效'
        }
        return statusMap[status]
      }
    },
    created() {
      this.getList()
      this.case_info_add = this.permissions['case_info_add']
      this.case_info_upd = this.permissions['case_info_upd']
      this.case_info_del = this.permissions['case_info_del']
    },
    methods: {
      getList() {
        this.listLoading = true;

        fetchList(this.listQuery).then(response => {
          this.list = response.data.records
          this.total = response.data.total
          this.listLoading = false
        })
      },
      gotoCaseInfo(row){
        this.$router.push({path:'/caseInfo',query:{cid:row.guid, bankname:this.$route.query.bankname}});
      },
      handleSizeChange(val) {
        this.listQuery.limit = val
        this.getList()
      },
      handleCurrentChange(val) {
        this.listQuery.page = val
        this.getList()
      },
      handleFilter() {
        this.listQuery.page = 1;
        this.getList();
      }
    }
  }
</script>
